'use strict';

const Controller = require('egg').Controller;


/**
* @controller PonPortsController 注释必写，swagger-doc是根据这段注释来生成接口的 ）。
*/

class PonPortsController extends Controller {
  async list() {
         /**
        * @summary ponPorts列表分页。
        * @description ponPorts列表分页。
        * @router get /ponportslist
        * @request query integer limit
        * @request query integer page
        * @request query String OltId
        * @request query String search
        */
    const params = this.ctx.query
    let result = await this.ctx.service.ponPorts.list(params)
    this.ctx.body = {
        msg:"",
        status: 200,
        data:result.rows,
        count:result.count
    }
  }
  async listAll(){
      /**
        * @summary ponPortslistall
        * @description ponPortslistall
        * @router get /ponportslistall
        * @request query String OltId
        */
    const params = this.ctx.query
    let result = await this.ctx.service.ponPorts.listAll(params)
    this.ctx.body = {
      msg:"",
      status: 200,
      data:result,
    }
  }
  async openAllPonPorts(){
     /**
        * @summary openAllPonPorts
        * @description openAllPonPorts
        * @router get /openallponports
        * @request query String oltId
        */
    const params = this.ctx.query
    let result = await this.ctx.service.ponPorts.openAllPonPorts(params)
    this.ctx.body = {
      status:200,
      data:result
    }
  }
  async getPonPortMsg(){
    /**
    * @summary 获取ponport的onus、距离、光功率
    * @description 获取ponport的onus、距离、光功率
    * @router get /getponportmsg
    * @request query String id
    */
   const params = this.ctx.query
   let result = await this.ctx.service.ponPorts.getPonPortMsg(params)
   this.ctx.body = {
     status:200,
     data:result
   }
  }
  async setPonPortMsg(){
    const params = this.ctx.request.body
    let result = await this.ctx.service.ponPorts.setPonPortMsg(params)
    this.ctx.body = {
      status:200,
      data:result
    }
  }
}

module.exports = PonPortsController;
